package main

import (
	"fmt"
	"time"
)

func main() {
	for nThreads := 1; nThreads <= 1000; nThreads *= 10 {
		c := make(chan struct{})
		exit := make(chan struct{})
		for i := 0; i < nThreads; i++ {
			go func() {
				for {
					select {
					case <-c:
						time.Sleep(time.Millisecond * 1)
					case <-exit:
						return
					}
				}
			}()
		}
		t0 := time.Now()
		n := 1000
		for i := 0; i < n; i++ {
			c <- struct{}{}
		}
		fmt.Printf("%10d %v\n", nThreads, time.Since(t0)/time.Duration(n))
		close(exit)
	}
}
